package com.powernode.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 自定义响应结果
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result <T>{
    private Integer code;
    private String message;
    private T data;

    public static Result success(){
        return new Result(200,"请求成功",null);
    }

    public static <T> Result<T> success (T data){
        return new Result<T>(200,"请求成功",data);
    }

    public static <T> Result success(String message,T data){
        return new Result(200,message,data);
    }

    public static Result failure(Integer code, String message){
        return new Result(code, message,null);
    }
}
